<?php
/**
 * <https://y.st./>
 * Copyright © 2017 Alex Yst <mailto:copyright@y.st>
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see <https://www.gnu.org./licenses/>.
**/

$xhtml = array(
	'<{title}>' => '32-bit integers!',
	'<{body}>' => <<<END
<section id="general">
	<h2>General news</h2>
	<p>
		I began the morning preparing to do laundry, but I quickly realised I wanted to clean the sinks with my dirty dish towel before washing it.
		The kitchen sink was full of dishes, and I&apos;m kind of tired of washing them by hand.
		I took a trip to Fred Meyer to get dish washer soap, and found some nice, eco-friendly powder.
		With the dishes loaded up, I scrubbed out both sinks, then started laundry.
	</p>
	<p>
		While the laundry machines did their thing, I worked on programming the bug fix for <code>minestats</code>.
		While I was at it, I almost-entirely rewrote the mod.
		I needed some code to be run after all mods had loaded, but before any players acted, so I looked for an $a[API] function I&apos;m almost certain I saw used in a subgame.
		If I recall, it took a function as an argument, then ran that function right before the map generator was set up.
		I searched through the properties and functions contained in the <code>minetest</code> table, but I never could find that function.
		Instead though, I found a function for retrieving a mod-specific data storage object.
		I looked into the documentation on it, and it&apos;s got the option of storing integer data, not just strings like what I&apos;ve been using.
		I tested it out with the numbers <code>99999999999999</code> and <code>-99999999999999</code>, the highest and lowest integers that Lua will correctly store as strings, along with the numbers just out of bounds, <code>100000000000000</code> and <code>-100000000000000</code>.
		I needed to know how the integer storage would handle these numbers.
		Would real integer storage allow me to transcend the limits of Lua number strings?
		As it turned out, no it did not.
		The results I got were kind of strange, too, and I didn&apos;t understand them at first.
		<code>99999999999999</code> got changed into a shorter number with seemingly-random digits.
		So the integer had less bits and it had hit its limit and stopped.
		There had to be dome sort of cap, right?
		Wrong!
		<code>100000000000000</code> had been translated into the number one higher than <code>99999999999999</code> had been.
		<code>-99999999999999</code> and <code>-100000000000000</code> had been translated to the negative versions of those same two numbers.
		I did some experimenting to try to find the threshold, and found that when the numbers I tried to store were in certain ranges, their signs flipped.
		The integers were looping!
		I decided to pull out my Galculator so find likely thresholds, and tried <code>2^32</code> and <code>-2^32</code>.
		Both were stored as zero.
		I&apos;d found my boundaries!
	</p>
	<p>
		Or, I suppose, not my boundaries, but my loop size.
		There&apos;s no limit, it just goes on forever.
		It&apos;s awesome!
		In a few minutes of spare time one day, I&apos;d already implemented that same sort of looping into my use of the Lua number strings, though I hadn&apos;t gotten a chance to commit that to the repo&apos; yet.
		Now, I had that same looping, but in a more natural way in my code (simply allowing the integer to wrap itself instead of testing the value of the integer before deciding to either increment or send to the far negative).
		Additionally, 32-bit integers are just so much cooler and geekier than signed, 14-digit, base-10 numbers, even if the 32-bit numbers have less storage potential.
		This is absolutely fantastic!
		I&apos;m so excited.
		The 32-bit integers are signed, but in cases where I need to know the value of the integer (as opposed to simply incriminating it), I unfold it to be unsigned, with a maximum value of <code>4294967295</code>.
		No one should reach the limit in my mod.
	</p>
	<p>
		As I said, I did a nearly-total rewrite of the mod.
		The mod now shows the player all minerals that can be collected before they&apos;ve found them.
		This lets players know what to look for, and also lets mod developers and server administrators very quickly test to see if their mods are supported.
		Minerals are also displayed in alphabetical order (by internal name, not player-facing name), not in order of which minerals a player has the most of.
		This provides consistent ordering.
		When mineral-defining mods are removed, the minerals they defined are no longer displayed as unknown items on the stats page, either.
		They&apos;re immediately hidden (though their data isn&apos;t removed, in case the mod is reinstalled later).
		If no minerals are defined, the stats page becomes hidden from all players.
		Support for <code>unified_inventory</code> has been dropped.
		<code>unified_inventory</code> is too inflexible for full support, so I implemented partial support before.
		Partial support makes my mod look broken though, so I&apos;m done with that.
		<code>unified_inventory</code> is an ugly mess, both in how it works and in how it looks.
		I&apos;m done with it.
		Everything&apos;s in working order, with one exception.
		The old database format is no longer used.
		I need to build code to read the old files, then add their data to the new database.
		Until I do that, I can&apos;t commit to the repo&apos;, as it&apos;ll break stuff for people that used an old version of my mod.
		I can do that, then remove the data from the files, but there are a couple of problems.
		First, I can&apos;t get a list of the existing files, each of which is named after a player.
		I have to wait until that player logs in, check to see if they have an old database file, then read it and update the main database.
		The second issue is that I can&apos;t remove the old files or the old directory.
		If I was writing a program, I could do it, but instead, I&apos;m working from within Minetest&apos;s sandbox.
	</p>
	<p>
		I forgot to change out of my work shoes until it was too late.
		The head manager was speeding things up, and brought my bike out from the back room.
		Normally, I&apos;d go back there to get it, and switch back to my street shoes while I was back there.
		It threw me off a little, and I forgot to change shoes until the manager had set the alarm and locked us both out.
		Oh, well.
		I&apos;ll get my street shoes back tomorrow.
	</p>
	<p>
		My <a href="/a/canary.txt">canary</a> still sings the tune of freedom and transparency.
	</p>
</section>
END
);
